const StatsPlugin = require('stats-webpack-plugin')

module.exports = {
  publicPath: process.env.VUE_APP_PUBLIC_PATH, // 默认'/'，部署应用包时的基本 URL
  outputDir: 'dist',
  assetsDir: 'static', // 相对于outputDir的静态资源(js、css、img、fonts)目录
  runtimeCompiler: true, // 是否使用包含运行时编译器的 Vue 构建版本
  productionSourceMap: false, // 生产环境的 source map
  devServer: {
    port: process.env.VUE_APP_PUBLIC_PORT,
    hot: true,
    headers:{'Access-Control-Allow-Origin':'*'}
  },
  configureWebpack: config => ({
    output: {
      library: 'singleChild2',
      libraryTarget: 'window'
    },
    plugins: [
      new StatsPlugin('manifest.json', {
        chunkModules: false,
        entrypoints: true,
        source: false,
        chunks: false,
        modules: false,
        assets: false,
        children: false,
        exclude: [/node_modules/]
      })
    ],
  }),
  chainWebpack: config => {},
  css: {
    extract: false,
    loaderOptions: {
      postcss: {
        plugins: [
          require('postcss-selector-namespace')({
            namespace () {
              return '#singleChild2'
            }
          })
        ]
      }
    }
  }
}
